#!/bin/bash
# Author: fanyongfeng
# 0 1 * * 6 /bin/bash /root/script/harbor_data_backup.sh &> /backup/harbor_data_backup/backup.log

TODAY=$(date +%Y%m%d)
BACKUP_DIR="/backup/harbor_data_backup"
DATA_DIR_NAME="harbor_data"

[ -d ${BACKUP_DIR} ] || mkdir -p ${BACKUP_DIR}

cd /data/
tar -cf - ${DATA_DIR_NAME} | pigz -v -p 16 -c - > ${BACKUP_DIR}/${DATA_DIR_NAME}.${TODAY}.tar.pigz
find ${BACKUP_DIR} -type f -name '*.tar.pigz' -mtime +7 | xargs -r -n 10 rm -f